package com.saihai.jiankang.ufZskgl.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.saihai.common.annotation.Log;
import com.saihai.common.core.controller.BaseController;
import com.saihai.common.core.domain.AjaxResult;
import com.saihai.common.enums.BusinessType;
import com.saihai.jiankang.ufZskgl.domain.UfZskgl;
import com.saihai.jiankang.ufZskgl.service.IUfZskglService;
import com.saihai.common.utils.poi.ExcelUtil;
import com.saihai.common.core.page.TableDataInfo;

/**
 * 健康咨询Controller
 * 
 * @author ruoyi
 * @date 2024-08-10
 */
@RestController
@RequestMapping("/jiankang/ufZskgl")
public class UfZskglController extends BaseController
{
    @Autowired
    private IUfZskglService ufZskglService;

    /**
     * 查询健康咨询列表
     */
    @GetMapping("/list")
    public TableDataInfo list(UfZskgl ufZskgl)
    {
        ufZskgl.setZt(0L);
        List<UfZskgl> list = ufZskglService.selectUfZskglList(ufZskgl);
        return getDataTable(list);
    }

    /**
     * 导出健康咨询列表
     */
    @Log(title = "健康咨询", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UfZskgl ufZskgl)
    {
        List<UfZskgl> list = ufZskglService.selectUfZskglList(ufZskgl);
        ExcelUtil<UfZskgl> util = new ExcelUtil<UfZskgl>(UfZskgl.class);
        util.exportExcel(response, list, "健康咨询数据");
    }

    /**
     * 获取健康咨询详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ufZskglService.selectUfZskglById(id));
    }

    /**
     * 新增健康咨询
     */
    @Log(title = "健康咨询", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UfZskgl ufZskgl)
    {
        return toAjax(ufZskglService.insertUfZskgl(ufZskgl));
    }

    /**
     * 修改健康咨询
     */
    @Log(title = "健康咨询", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UfZskgl ufZskgl)
    {
        return toAjax(ufZskglService.updateUfZskgl(ufZskgl));
    }

    /**
     * 删除健康咨询
     */
    @Log(title = "健康咨询", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ufZskglService.deleteUfZskglByIds(ids));
    }
}
